package com.bootssm.service.impl;


import com.bootssm.dao.AddresslistMapper;
import com.bootssm.entity.Contact;
import com.bootssm.entity.ContactVO;
import com.bootssm.service.AddresslistService;
import com.bootssm.utils.IdWorker;
import com.bootssm.utils.TimeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class AddresslistImpl implements AddresslistService {
   @Autowired
    AddresslistMapper addresslistMapper;

   @Autowired
    IdWorker idWorker;
    @Override
    public List<Contact> findAll(ContactVO contactVO) {
        return addresslistMapper.findAll(contactVO);
    }

    @Override
    public Integer getCount(ContactVO contactVO) {
        return addresslistMapper.getCount(contactVO);
    }

    @Override
    public void insert(Contact contact) {
        contact.setContactid(idWorker.nextId()+"");
        contact.setAddtime(TimeUtil.getCurrentTime(new Date()));
        addresslistMapper.insert(contact);
    }

    @Override
    public void update(Contact contact) {
        addresslistMapper.update(contact);
    }

    @Override
    public void deleteById(String contactid) {
        addresslistMapper.deleteById(contactid);
    }

    @Override
    public Contact findById(String contactid) {
        return addresslistMapper.findById(contactid);
    }

}
